package com.cc8w.service;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

import org.springframework.stereotype.Service;

/**
 * Url类测试
 */
@Service
public class UrlService {
	private URL Url;

	public URL getUrl() {
		return Url;
	}

	public void setUrl(URL url) {
		Url = url;
	}

	//重写URL方法
	public void setUrl(String url) {
		try {
			Url = new URL(url);
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	//获得URL对象中的字节内容（这里会牵扯几种流的转换,可以详细的注意下）
	public InputStream getUrlByte() throws IOException {
		if(Url==null) return null;
		InputStream is = Url.openStream();	
		System.out.println(is);
		return is;
	}
	

	
	
	
	
	
	
	
	
	
	
	
	
	
}
